#include "QBProviceInfo.h"

#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
//#define new DEBUG_NEW
#endif

//////////////////////////////////////////////////////////////////////
// class CQBProvinceInfo

CQBProvinceInfo::CQBProvinceInfo()
{
}

CQBProvinceInfo::~CQBProvinceInfo()
{
	Clear( );
}

bool CQBProvinceInfo::Add( QBPROVINCEINFO & info ){
	//std::lock_guard<std::mutex> locker(m_mutex);//TODO:
	if (info.Area_Code[0] == '\0')return false;
	m_map[info.Area_Code] = info;
	return true;
}

bool CQBProvinceInfo::Clear( )
{
	std::lock_guard<std::mutex> locker(m_mutex);
	m_map.clear();
	return true;
}

CQBProvinceInfo& CQBProvinceInfo::instance()
{
	static CQBProvinceInfo s_pi;
	return s_pi;
}

const QBPROVINCEINFO* CQBProvinceInfo::GetProviceInfo(const std::string &id){
	std::lock_guard<std::mutex> locker(m_mutex);
	std::map<std::string, QBPROVINCEINFO>::iterator it = m_map.find(id);
	if(it != m_map.end()){
		return &it->second;
	}
	return NULL;
}

void CQBProvinceInfo::DumpStatus(int mode)const
{
}